package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.SetingsMapper;
import com.tanhua.model.domain.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SettingsApiImpl implements SettingApi{

    @Autowired
    private SetingsMapper setingsMapper;

    /*用户通知设置 - 读取*/
    @Override
    public Settings findByUserId(Long userId) {
        QueryWrapper qw=new QueryWrapper();
        qw.eq("user_id",userId);
        return setingsMapper.selectOne(qw);
    }

    /*用户通知设置 - 保存(添加)*/
    @Override
    public void save(Settings settings) {
        setingsMapper.insert(settings);
    }

    /*用户通知设置 - 更新*/
    @Override
    public void update(Settings settings) {
        setingsMapper.updateById(settings);
    }
}
